#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,r,l) for(int i=(r);i>=(l);i--)
using namespace std;
int rd() {int x=0,f=1;char c=getchar();while(!isdigit(c))f=c=='-'?-1:f,c=getchar();while(isdigit(c))x=x*10+(c^48),c=getchar();return x*f;}
const int N=100005;
int n,m,L,V,d[N],v[N],a[N],p[N];
struct seg{int l,r;}s[N],t[N];
bool operator<(seg a,seg b) {return a.l!=b.l?a.l>b.l:a.r<b.r;}
void Main() {
    int ans=0,tot=0;
    n=rd(),m=rd(),L=rd(),V=rd();
    rep(i,1,n) d[i]=rd(),v[i]=rd(),a[i]=rd();
    rep(i,1,m) p[i]=rd();
    rep(i,1,n) {
        int l=1,r=0;
        if(a[i]==0&&v[i]>V) {
            l=lower_bound(p+1,p+1+m,d[i])-p;
            r=m;
        }
        if(a[i]>0) {
            int x=max(d[i],(int)(d[i]+ceil((long double)(V*V-v[i]*v[i])/(2*a[i])+0.000000001)));
            l=lower_bound(p+1,p+1+m,x)-p;
            r=m;
        }
        if(a[i]<0&&v[i]>V) {
            int x=d[i]+floor((long double)(V*V-v[i]*v[i])/(2*a[i])-0.000000001);
            l=lower_bound(p+1,p+1+m,d[i])-p;
            r=upper_bound(p+1,p+1+m,x)-p-1;
        }
        // printf("i=%d l=%d r=%d\n",i,l,r);
        if(l<=r) ans++,s[++tot]={l,r};
    }
    sort(s+1,s+1+tot);
    int cnt=0;
    // rep(i,1,tot) printf("[%d,%d] ",s[i].l,s[i].r);puts("");
    int mn=1e9;
    rep(i,1,tot) {
        if(i==1||s[i].r<mn) t[++cnt]=s[i];
        mn=min(mn,s[i].r);
    }
    reverse(t+1,t+1+cnt);
    // rep(i,1,cnt) printf("[%d,%d] ",t[i].l,t[i].r);puts("");
    int lst=0,sum=0;
    rep(i,1,cnt) if(lst<t[i].l) lst=t[i].r,sum++;
    printf("%d %d\n",ans,m-sum);
}
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T=rd();
    while(T--) Main();
    return 0;
}
//g++ -std=c++14 -O2 -Wall -fsanitize=address,undefined -o detect detect.cpp